using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Tests.ItemEventArgs
{
    [TestClass]
    public class ItemEventArgsTester
    {
        [TestMethod]
        public void ConstructorShouldSetItemField()
        {
            ItemEventArgs<int> args = new ItemEventArgs<int>(1);
            int actual = (int) args.GetType().GetField("item", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(args);

            int expected = 1;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void SetItemShouldAssignValueToField()
        {
            ItemEventArgs<int> args = new ItemEventArgs<int>(1);
            args.Item = 2;

            int actual = (int) args.GetType().GetField("item", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(args);

            int expected = 2;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetItemShouldReturnValueFromField()
        {
            ItemEventArgs<int> args = new ItemEventArgs<int>(1);
            args.Item = 2;

            int actual = args.Item;

            int expected = 2;

            Assert.AreEqual(expected, actual);
        }
    }
}